package real.evaluation;


import real.lang.RealLangException;
import real.lang.RealObject;

public class SymbolConstruction extends SyntacticalConstruction<RealObject> {

	private String symbolName;

	/**
	 * @param symbolName
	 *            the symbolName to set
	 */
	public void setSymbolName(String symbolName) {
		this.symbolName = symbolName;
	}

	/**
	 * @return the symbolName
	 */
	public String getSymbolName() {
		return symbolName;
	}

	public RealObject Evaluate(Evaluator eval) throws RealLangException {
		// TODO throw exception if null
		return eval.getSymbol(symbolName);
	}

	public SymbolConstruction(String name) {
		this.symbolName = name;
	}

	@Override
	protected RealObject ProperEvaluate(Evaluator eval)
			throws RealLangException {
		RealObject res = eval.getSymbol(symbolName);
		if (res == null) throw new RealEvaluationException("Null pointer instead of symbol");
		return res;
	}

}
